package kr.saeildamil.androidstudy_second.fragment;

import java.util.zip.Inflater;

import kr.saeildamil.androidstudy_second.R;
import android.app.Activity;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class DialogFragmentTest extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch20_dialogfragment);
	}
	public void mOnClick(View v){
		FragmentManager fm = getFragmentManager();
		FragmentTransaction tr = fm.beginTransaction();
		Fragment prev = fm.findFragmentByTag("dialog");
		if(prev != null){
			tr.remove(prev);
		}
		NameGenderFragment dialog = new NameGenderFragment();
		dialog.show(tr,"dialog");
		
	}
	public static class NameGenderFragment extends DialogFragment{
		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View root = inflater.inflate(R.layout.ch20_namegenderfragment, container, false);
			return root;
		}
	}
}
